<template>

    <div class="login-back" >
      <Input id="name" style="width: 25%;margin-top: 20%;align-content: center" v-model="name" placeholder="请输入名字"/><br><br>
      <Input id="password" style="width:  25%;align-content: center" v-model="password" type="password" placeholder="请输入密码"/><br><br>
      <Button type="primary" style=" align-content: center" @click="userLogin('formInline')">Login</Button>
      <router-view/>
    </div>

</template>
<script>

export default {
  name: 'VmLogin',
  data: function () {
    return {
        name:'',
      password:'',
      formInline: {
        name: '',
        password: ''

      }
    }
  },
  methods: {
    userLogin() {
        this.formInline.password=this.password;
      this.formInline.name=this.name;

      this.$http.post('/login', this.formInline).then(
        function (res) {

          if (res.data.body !=null) {
            this.$Message.success('登陆成功');
            console.log(this.$router);
          this.$router.push('/home');

          } else {
            this.$Message.error('登陆失败');
            return false;
          }
        }
      )
    }
  }
}
</script>
<style>

  .login-back {

    background: url(../assets/img/bg2.png) no-repeat;
    background-size: cover;
    height: 100%;
    width: 100%;
    position: fixed;
  }
</style>
